package com.example.mapper;

import com.example.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("INSERT INTO users (username, password_hash, salt, email, phone, gender, created_at) " +
            "VALUES (#{username}, #{passwordHash}, #{salt}, #{email}, #{phone}, #{gender}, NOW())")
    int insertUser(User user);

    @Delete("DELETE FROM users WHERE user_id = #{userId}")
    int deleteUserById(Integer userId);

    @Update("UPDATE users SET username = #{username}, email = #{email}, phone = #{phone}, gender = #{gender} " +
            "WHERE user_id = #{userId}")
    int updateUser(User user);

    @Select("SELECT * FROM users WHERE user_id = #{userId}")
    User getUserById(Integer userId);

    @Select("SELECT * FROM users")
    List<User> getAllUsers();
}
